App({

  onShow: function (options) {
    console.log(options)
    var scene = options.scene;
    this.globalData.scene = scene;
  },

  onLaunch: function (options) {
    var that = this;
    console.log(options.query)
    if (options.query.openid != undefined && options.query.user_id != undefined) {
      wx.setStorageSync('openid', options.query.openid);
      wx.setStorageSync('user_id', options.query.user_id);
    }

    wx.login({
      success: function (res) {
        console.log(res);
        wx.request({
          url: that.globalData.openIdUrl,
          data: {
            code: res.code,
            type: 'user',
          },
          header: {
            "Content-Type": "application/x-www-form-urlencoded"
          },
          success: function (res) {
            console.log('12345' + res.data);
            that.globalData.openIdPay = res.data.openid;
          },
          complete: function (res) {
            console.log(res);
          },
        })
      }
    })
  },
  globalData:{
    scene: 0,
    userInfo: null,
    apiUrl:'https://api.zntech-china.com/Public/hongbao',
    //apiUrl: 'https://wx.zonuo-china.com/hongbao_api/Public/hongbao',

    openIdUrl: 'https://mylife.zntech-china.com/web/get_wx_open_id',//获取支付openid接口
    openIdPay: '',//支付openid
    payUrl: 'https://mylife.zntech-china.com/web/get_pay_wx',//支付接口
  }
})
